package order.server;

import order.api.ProductApi;
import order.dao.OrderInfo;
import order.dao.ProductInfo;
import order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;


@Service
public class OrderServer {

    @Autowired
    OrderMapper orderMapper;
    @Autowired
    RestTemplate restTemplate;
    @Autowired
    ProductApi productApi;

//    openfeign来简化微服务之间的调用 这样就不用拼接url了
    public OrderInfo getOrderById(int orderId) {

        OrderInfo orderInfo = orderMapper.selectById(orderId);

        ProductInfo productInfo = productApi.getProductInfo(orderInfo.getProductId());

        orderInfo.setProductInfo(productInfo);

        return orderInfo;
    }
}